package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.BusinessSealtype;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IBusinessSealtypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务系统对应印章Controller
 * 
 * @author ess
 * @date 2021-12-03
 */
@RestController
@RequestMapping("/system/businessSealType")
public class BusinessSealtypeController extends BaseController
{
    @Autowired
    private IBusinessSealtypeService businessSealtypeService;

    /**
     * 查询业务系统对应印章列表
     */
    @PreAuthorize("@ss.hasPermi('system:businessSealType:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessSealtype businessSealtype)
    {
        startPage();
        List<BusinessSealtype> list = businessSealtypeService.selectBusinessSealtypeList(businessSealtype);
        return getDataTable(list);
    }

    /**
     * 导出业务系统对应印章列表
     */
    @PreAuthorize("@ss.hasPermi('system:businessSealType:export')")
    @Log(title = "业务系统对应印章", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusinessSealtype businessSealtype)
    {
        List<BusinessSealtype> list = businessSealtypeService.selectBusinessSealtypeList(businessSealtype);
        ExcelUtil<BusinessSealtype> util = new ExcelUtil<BusinessSealtype>(BusinessSealtype.class);
        return util.exportExcel(list, "业务系统对应印章数据");
    }

    /**
     * 获取业务系统对应印章详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:businessSealType:query')")
    @GetMapping(value = "/{businessId}")
    public AjaxResult getInfo(@PathVariable("businessId") String businessId)
    {
        return AjaxResult.success(businessSealtypeService.selectBusinessSealtypeByBusinessId(businessId));
    }

    /**
     * 新增业务系统对应印章
     */
    @PreAuthorize("@ss.hasPermi('system:businessSealType:add')")
    @Log(title = "业务系统对应印章", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessSealtype businessSealtype)
    {
        return toAjax(businessSealtypeService.insertBusinessSealtype(businessSealtype));
    }

    /**
     * 修改业务系统对应印章
     */
    @PreAuthorize("@ss.hasPermi('system:businessSealType:edit')")
    @Log(title = "业务系统对应印章", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessSealtype businessSealtype)
    {
        return toAjax(businessSealtypeService.updateBusinessSealtype(businessSealtype));
    }

    /**
     * 删除业务系统对应印章
     */
    @PreAuthorize("@ss.hasPermi('system:businessSealType:remove')")
    @Log(title = "业务系统对应印章", businessType = BusinessType.DELETE)
	@DeleteMapping("/{businessIds}")
    public AjaxResult remove(@PathVariable String[] businessIds)
    {
        return toAjax(businessSealtypeService.deleteBusinessSealtypeByBusinessIds(businessIds));
    }

//印章授权页面获取
//    @PreAuthorize("@ss.hasPermi('system:businessSealType:query')")
    @GetMapping("/getBusinessSealTypeOptions")
    public AjaxResult getBusinessSealTypeOptions()
    {
        return AjaxResult.success(businessSealtypeService.getBusinessSealTypeOptions());
    }

}
